package com.tddx.activiti.utils.gentiJava;

import java.util.List;

public class GenJspContent {
	
	public static String getResultContent(){
		
		StringBuffer sb = new StringBuffer();
		sb.append("<%@page language=\"java\" contentType=\"text/html;charset=UTF-8\"%>\r\n");
		sb.append("<%@taglib uri=\"/WEB-INF/tld/csmis.tld\" prefix=\"csmis\"%>\r\n");
		sb.append("<%@include file=\"/common/include.jsp\"%>\r\n");
		sb.append("<!DOCTYPE html>\r\n");
		sb.append("<html>\r\n");
		sb.append("<head>\r\n");
		sb.append("	<meta charset=\"UTF-8\">\r\n");
		sb.append("	<title>列表</title>\r\n");
		sb.append("	<link rel=\"stylesheet\" type=\"text/css\" href=\"/csmis/js/easyui1.4.3/themes/default/easyui.css\">\r\n");
		sb.append("	<link rel=\"stylesheet\" type=\"text/css\" href=\"/csmis/js/easyui1.4.3/themes/icon.css\">\r\n");
		sb.append("	<link rel=\"stylesheet\" type=\"text/css\" href=\"/csmis/js/easyui1.4.3/demo/demo.css\">\r\n");
		sb.append("	<link rel=\"stylesheet\" type=\"text/css\" href=\"/csmis/css/public.css\">\r\n");
		sb.append("	<script type=\"text/javascript\" src=\"/csmis/js/easyui1.4.3/jquery.min.js\"></script>\r\n");
		sb.append("	<script type=\"text/javascript\" src=\"/csmis/js/easyui1.4.3/jquery.easyui.min.js\"></script>\r\n");
		sb.append("	<script type=\"text/javascript\" src=\"/csmis/js/easyui1.4.3/datagrid-filter.js\"></script>\r\n");
		sb.append("	<script type=\"text/javascript\" src=\"/csmis/js/easyui1.4.3/locale/easyui-lang-zh_CN.js\"></script>\r\n");
		sb.append("</head>\r\n");
		sb.append("<body>\r\n");
		sb.append("	<div id=\"msg\" style=\"color: red\"></div>\r\n");
		sb.append("	<table id=\"dg\" class=\"easyui-datagrid\" title=\"列表\" style=\"width:100%;\"\r\n");
		sb.append("		data-options=\"singleSelect:false,nowrap:false,fit:true,remoteSort:false,multiSort:true,toolbar:'#tb'\">\r\n");
		sb.append("		<thead>\r\n");
		sb.append("			<tr>\r\n");
		
		//增加列表的列
		sb.append(getResultList());
		
		sb.append("			</tr>\r\n");
		sb.append("	<div id=\"tb\" style=\"padding:2px 5px;\">\r\n");
		sb.append("	<div>\r\n");
		sb.append("		<form id='searchTable' method=\"post\" action='export.action'>\r\n");
		sb.append("			//增加条件");
		sb.append("			<label>录入日期从:\r\n");
		sb.append("				<input class=\"easyui-datebox\" name=\"beginDate\" style=\"width:110px\" value=\"${searchTable.beginDate }\">\r\n");
		sb.append("			</label>\r\n");
		sb.append("			<label>到:\r\n");
		sb.append("				<input class=\"easyui-datebox\" name=\"endDate\" style=\"width:110px\" value=\"${searchTable.endDate }\">\r\n");
		sb.append("			</label>\r\n");
		sb.append("		</form>\r\n");
		sb.append("	</div>\r\n");
		sb.append("		<div style=\"padding:2px 5px;\">\r\n");
		sb.append("			<a href=\"#\" class=\"easyui-linkbutton add\" iconCls=\"icon-add\" plain=\"true\">添加</a>\r\n");
		sb.append("			<a href=\"#\" class=\"easyui-linkbutton modify\" iconCls=\"icon-add\" plain=\"true\">修改</a>\r\n");
		sb.append("			<a href=\"#\" class=\"easyui-linkbutton remove\" iconCls=\"icon-add\" plain=\"true\">删除</a>\r\n");
		sb.append("			<a href=\"#\" class=\"easyui-linkbutton view\" iconCls=\"icon-add\" plain=\"true\">查看</a>\r\n");
		sb.append("		</div>\r\n");
		sb.append("	</div>\r\n");
		sb.append("</body>\r\n");
		sb.append("</html>\r\n");
		return sb.toString();
		
	}
	
	public static String getJspContent(String oper){
		
		StringBuffer sb = new StringBuffer();
		sb.append("<%@page language=\"java\" contentType=\"text/html;charset=UTF-8\"%>\r\n");
		sb.append("<%@taglib uri=\"/WEB-INF/tld/csmis.tld\" prefix=\"csmis\"%>\r\n");
		sb.append("<%@include file=\"/common/include.jsp\"%>\r\n");
		sb.append("<!DOCTYPE html>\r\n");
		sb.append("<html>\r\n");
		sb.append("<head>\r\n");
		sb.append("	<meta charset=\"UTF-8\">\r\n");
		sb.append("	<title>录入</title>\r\n");
		sb.append("</head>\r\n");
		sb.append("<body>\r\n");
		
		sb.append(getViewList(oper));
		
		sb.append("</body>\r\n");
		sb.append("</html>\r\n");
		return sb.toString();
		
	}
	
	public static String getResultList(){
		List<TablePro> list = Constants.tableProlist;
		StringBuffer sb = new StringBuffer();
		sb.append("					<th data-options=\"field:'id',checkbox:true\"></th>\r\n");
		for(TablePro tp: list){
			if(tp.getColName()=="id"){
				continue;
			}
			sb.append("				<th data-options=\"field:'" + GenContent.getProName(tp.getColName()) + "',width:100,align:'center'\">" + tp.getComments() + "</th>\r\n");
		}
		return sb.toString();
	}
	
	public static String getViewList(String oper){
		List<TablePro> list = Constants.tableProlist;
		StringBuffer sb = new StringBuffer();
		sb.append("	<form method=\"post\" id=\"entity\">\r\n");
		sb.append("		<table cellpadding=\"5\">");
		sb.append("			<input type=\"hidden\" name=\"id\" value=\"${entity.id }\"/>\r\n");
		for(TablePro tp: list){
			if(tp.getColName()=="id"){
				continue;
			}
			String colName = GenContent.getProName(tp.getColName());
			sb.append("			<tr>\r\n");
			sb.append("				<td>" + tp.getComments() + "</td>\r\n");
			sb.append("				<td>");
			if("view".equals(oper)){
				sb.append("					${entity." + colName + " }\r\n");
			}else {
				if(DataType.DATE.toString().equals(tp.getDataType())){
					sb.append("					<input class=\"easyui-datetimebox\" name=\"" + colName + "\" id=\"" + colName + "\" value=\"${entity." + colName + " }\" data-options=\"required:true\" style=\"width:200px;height:26px\">\r\n");
				}else{
					sb.append("					<input class=\"easyui-textbox\" name=\"" + colName + "\" id=\"" + colName + "\" value=\"${entity." + colName + " }\" data-options=\"required:true\" style=\"width:200px;height:26px\">\r\n");
				}
			}
			sb.append("				</td>\r\n");
			sb.append("			</tr>\r\n");
		}
		sb.append("		</table>");
		sb.append("	</form>");
		return sb.toString();
	}
	
	
}
